import ObstacleCre
import Plotmaze
import Qlearning
from Node import Point
import pickle


length = 20
width = 20
height = 10  # 地图为20*20*10的三维地图

greedy = 0.2  # 训练中时80%采取贪婪算法选取动作act
learningrate = 0.7  # 学习率设定
maxstepnum = 1000  # 最大步数
obstacleNum = int(length * width * 0.2)  # 障碍物数目
startPoint = (0,0,0)  # 起点初始化
endPoint = (length-1,width-1,int(0.5*height)-1)  # 终点初始化
learningtimes = 450000000  # 学习时长

obstacle = ObstacleCre.ObstacleCreate(obstacleNum, length, width, height,startPoint,endPoint)  # 生成障碍物
Plotmaze.plotmaze(obstacle, startPoint, endPoint)  # 画出障碍物图
this = Qlearning.Map(length, width, height, startPoint, endPoint,obstacle, greedy, learningrate)  # 实例化RL
dict = this.initMap()  # 初始化地图信息
this.resetR()  # 更改部分地图信息
print("初始化完毕！")
this.run(maxstepnum,learningtimes)  # 训练开始

